package java67_15;

public class Teacher2 {
	private String name;
	private int age;
	private String qulification;
	private String position;

	/**
	 * 有了构造方法,无参的就不加了.
	 * 
	 * @param n
	 * @param a
	 * @param q
	 * @param p
	 */
	public Teacher2(String n, int a, String q, String p) {
		name = n;
		// age = a;//!!!!!!!!!!
		setAge(a);
		qulification = q;
		position = p;
	}

	// 只有一个name被初始化
	public Teacher2(String n) {
		name = n;
		age = 30;
		qulification = "不清楚";
		position = "待定";
	}

	// 初始化name和age
	public Teacher2(String n, int a) {
		name = n;

		setAge(a);
	}

	// 初始化name和学历
	public Teacher2(String n, String q) {
		name = n;
		qulification = q;
	}

	// 初始化name和职务,和上一个构造方法冲突
//	public Teacher2(String n, String pos) {
//		name = n;
//		position = pos;
//	}

	public void selfIntro() {
		System.out.println("姓名 " + name + ",年龄 " + age + "岁,学历 " + qulification + " ,职务是 " + this.position);
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getAge() {
		// 不允许
		// Teacher2("sss", 22, "222", "444");

		return age;
	}

	public void setAge(int age) {
		if (age < 22) {
			System.err.println("年龄赋值错误,至少是22岁,您输入的是:" + age + "岁");
			age = 22;
		}
		this.age = age;
	}

	public String getQulification() {
		return qulification;
	}

	public void setQulification(String qulification) {
		this.qulification = qulification;
	}

	public String getPosition() {
		return position;
	}

	public void setPosition(String position) {
		this.position = position;
	}
}
